package com.wiscamp.ninechapters.problems.infrastructure.mappers.exams;

import com.wiscamp.ninechapters.problems.infrastructure.po.exams.PaperSectionView;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Collection;

/**
 * 试卷节数据访问对象
 *
 * @author yifeng
 */
@Repository
public interface PaperSectionViewMapper extends JpaRepository<PaperSectionView, Long>, JpaSpecificationExecutor<PaperSectionView> {
    /**
     * 通过试卷部分编号获取试卷节列表
     *
     * @param partId
     * @return
     */
    @Query(value = "select s from PaperSectionView s where s.partId = :partId order by s.sectionIndex asc")
    Collection<PaperSectionView> findListByPart(long partId);

    @Query(value = "select s from PaperSectionView s where s.partId in :partIds order by s.sectionIndex asc")
    Collection<PaperSectionView> findListByParts(Collection<Long> partIds);
}